BASEDIR = .

TARGET = $(BASEDIR)/target/
SOURCE = $(BASEDIR)/src/
INCLUDE = $(BASEDIR)/include/
LIBRARIES = $(BASEDIR)/lib/

LIBRARIES_USB = C:/Libraries/lubusb/lubusb-win32-bin-1.2.5.0/lib/gcc
LIBRARIES_INCLUDE = C:/Libraries/libusb/libusb-win32-bin-1.2.5.0/include
BOOST_INCLUDE = C:/Boost/boost_1_47_0
LOGGER_INCLUDE = C:/Users/ludmilla/workspace/logger
JAVA_INCLUDE = "C:/Program Files/Java/jdk1.6.0_26/include"
JAVA_WIN32_INCLUDE = "C:/Program Files/Java/jdk1.6.0_26/include/win32"

all :

javah :	../jusb/src/fregat/microchip/usb/jusb.java
	javah -classpath ../jusb/target/classes -jni -d ./src fregat.microchip.usb.jusb

$(TARGET)usb_interface.o : $(SOURCE)usb_interface.cpp $(SOURCE)usb_interface.h
	g++ -ggdb -I$(LIBRARIES_INCLUDE) \
	-I$(BOOST_INCLUDE) -I$(JAVA_WIN32_INCLUDE) \
	-I$(JAVA_INCLUDE) -O3 -Wall -c -fmessage-length=0 \
	-o$(TARGET)usb_interface.o $(SOURCE)usb_interface.cpp

$(TARGET)usb_utility.o :	$(SOURCE)usb_utility.h $(SOURCE)usb_utility.cpp
	g++ -ggdb -I$(LIBRARIES_INCLUDE) -I$(BOOST_INCLUDE) -I$(LOGGER_INCLUDE) \
	-I$(INCLUDE) -I$(JAVA_WIN32_INCLUDE) -I$(JAVA_INCLUDE) \
	-O3 -Wall -c -fmessage-length=0 -o$(TARGET)usb_utility.o $(SOURCE)usb_utility.cpp

./target/jusb.o :	./src/jusb.cpp ./src/jusb.h ./src/fregat_microchip_usb_jusb.h
	g++ -ggdb -IC:/Libraries/libusb/libusb-win32-bin-1.2.4.0/include \
		-IC:/Users/fregat/workspace.pic/test_jusbdll/include \
		-IC:/boost/boost_1_37_0 -I"C:/Program Files/Java/jdk1.6.0_19/include/win32" \
		-I"C:/Program Files/Java/jdk1.6.0_19/include" -O3 -Wall \
		-c -fmessage-length=0 -o./target/jusb.o ./src/jusb.cpp

./target/libjusbdll.dll :	$(TARGET)jusb.o $(TARGET)usb_utility.o $(TARGET)usb_interface.o $(LIBRARIES)logger.o
	g++ -Wall -D_JNI_IMPLEMENTATION_ -Wl,--kill-at -LC:/Libraries/libusb/libusb-win32-bin-1.2.4.0/lib/gcc \
		-shared -o./target/libjusbdll.dll ./target/usb_utility.o ./lib/logger.o \
		./target/usb_interface.o ./target/jusb.o  -lusb
	cp ./target/libjusbdll.dll ../jusb/lib/
	cp ./target/libjusbdll.dll ../jusb_mchpusb/lib/
	
./target/test.o :	./src/main.cpp
	g++ -Wall  -ggdb -c \
		-I$(LIBRARIES_INCLUDE) \
		-I$(BOOST_INCLUDE) -I$(JAVA_WIN32_INCLUDE) -I$(LOGGER_INCLUDE) \
		-I$(JAVA_INCLUDE) \
		-I$(INCLUDE) \
		-fmessage-length=0 -o./target/test.o ./src/main.cpp

#./target/test.exe :	./target/jusb.o ./target/usb_utility.o ./target/usb_interface.o ./lib/logger.o ./target/test.o
#	g++ -Wall -Wl, --kill-at -LC:/Libraries/libusb/libusb-win32-bin-1.2.4.0/lib/gcc \
		-o./target/test.exe ./target/usb_utility.o ./lib/logger.o \
		./target/usb_interface.o ./target/jusb.o ./target/test.o -lusb
		
./target/test.exe :	./lib/logger.o ./target/test.o ./target/usb_interface.o ./target/usb_utility.o
	g++ -Wall -Wl --kill-at -LC:/Libraries/libusb/libusb-win32-bin-1.2.5.0/lib/gcc \
	-o./target/test.exe ./lib/logger.o ./target/test.o ./target/usb_interface.o ./target/usb_utility.o -lusb




test :	test.test
	@echo "make test"
	
#	usb:	jusb.c jusb.h
#	gcc -Wall -D_JNI_IMPLEMENTATION_ -Wl,--kill-at -Ic:/Programme/Java/jdk1.6.0_12/include \
#	-Ic:/Programme/Java/jdk1.6.0_12/include/win32 -shared jusb.c -o jusb.dll